from django.db import models

from utils.BaseModel import BaseModel


# Create your models here.
class Nav(BaseModel):
    name = models.CharField(max_length=20, verbose_name='导航名称')
    sort = models.IntegerField(verbose_name='排序')
    url = models.CharField(max_length=100, verbose_name='跳转路径')
    class Meta:
        db_table = '03_nav'
        verbose_name_plural = '导航信息'
    def __str__(self):
        return self.name
class Category(BaseModel):
    name=models.CharField(max_length=50,verbose_name="分类名称")
    level=models.IntegerField(default=1,verbose_name="分类级别")
    #无限极分类模型 使用外键形式 指向的是自己
    parent=models.ForeignKey("self",on_delete=models.CASCADE,null=True,blank=True,verbose_name="上级分类")
    sort=models.IntegerField(default=0,verbose_name="排序")
    class Meta:
        db_table="03_category"
    def __str__(self):
        return self.name